import 'package:flutter/material.dart';

extension GlobalThemeExtension on BuildContext {
  /**
   * 主题色的卡片背景, 支持自定义圆角
   *
   * 使用方式
   * ```dart
   * Container(
   *   decoration: context.createDecoration(
   *   topRight: 40,
   *   topLeft: 40,
   *   bottomLeft: 40,
   *   bottomRight: 40),
   * )
   * ```
   * 或者默认10圆角
   * ``` 
   * Container(
   *   decoration: context.createDecoration(),
   * )
   * ```
   **/
  BoxDecoration createDecoration(
      {double topLeft = 10.0,double topRight = 10.0,double bottomLeft = 10.0,double bottomRight = 10.0,Border? border = null}) {
    return BoxDecoration(
      color: Theme.of(this).cardColor, //
      borderRadius: BorderRadius.only(
          topLeft: Radius.circular(topLeft),
          topRight: Radius.circular(topRight),
          bottomLeft: Radius.circular(bottomLeft),
          bottomRight: Radius.circular(bottomRight)),
      boxShadow: [
        BoxShadow(
          color: Theme.of(this).shadowColor,
          spreadRadius: 0,
          blurRadius: 3,
          offset: const Offset(0, 0),
        )
      ],
      border: border
    );
  }
}
